<template>
    <div>
        <div>
            <el-input class="searchInput" 
                    clearable
					@clear="keywordClear"
                    v-model="keyword"
                    placeholder="请输入公司关键字进行搜索..."
                    @keydown.enter.native="doSearch"
                    prefix-icon="el-icon-search">
            </el-input>
            <el-button icon="el-icon-search" type="primary" @click="doSearch">搜索</el-button> 
        </div>
        <div class="baseMain">
            <el-table
                    :data="declares"
                    border
                    stripe
                    style="width:60%">
                <el-table-column
                    prop="baseName" label="公司名字" width="260">
                </el-table-column>
                <el-table-column
                    prop="city" label="所在城市" width="80">
                </el-table-column>
				<el-table-column
				    prop="createTime" label="申报时间" width="160">
				</el-table-column>
				<el-table-column
				    prop="updateTime" label="审核时间" width="160">
				</el-table-column>
                <el-table-column
                    prop="status" label="审核状态">
					<template slot-scope="scope">
						<el-tag  type="info" v-if="scope.row.status == 0">审核中</el-tag>
						<el-tag  type="success" v-if="scope.row.status == 1">已通过</el-tag>
						<el-tag  type="danger" v-if="scope.row.status == 2">未通过</el-tag>
					</template>
                </el-table-column>
            </el-table>
        </div>
		<div class="pageSelect">
			<el-pagination
				  @current-change="handleCurrentChange"
				  :current-page="current"
				  :page-size="size"
				  layout="total, prev, pager, next"
				  :total="total">
			</el-pagination>
		</div>
    </div>
</template>

<script>
    export default {
        data () {
            return {
                declares:[],
                keyword:'',
				current: 1,
				size: 10,
				total: 0,
                
            }
        },
		mounted() {
			this.initDeclares();
		},
        methods: {
			initDeclares(){
				let url = '/base/declare/?current=' + this.current + '&size=' + this.size + '&keyword=' + this.keyword;
				this.getRequest(url).then(resp =>{
					if(resp){
						this.declares = resp.data;
						this.total = resp.total;
					}
				})
			},
			keywordClear(){
				this.current = 1;
				this.initDeclares();
			},
            doSearch(){
				this.current = 1;
                this.initDeclares();
            },
			handleCurrentChange(currentPage){
				this.current = currentPage;
				this.initDeclares();
			}
        }
    }
</script>

<style scoped>
    .searchInput{
        width: 300px;
        margin-right: 8px;
    }
    .baseMain{
        margin-top: 10px;
    }
	.pageSelect{
		width: 60%;
		margin-top: 5px;
		display: flex;
		justify-content: flex-end;
	}
</style>